﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dycox.ComponentModel
{
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public sealed class VisibleAttribute : Attribute
    {
        public VisibleAttribute(bool visible)
        {
            _visible = visible;
        }

        private bool _visible;

        public bool Visible
        {
            get { return _visible; }
            set { _visible = value; }
        }

        // override object.Equals
        public override bool Equals(object obj)
        {
            //       
            // See the full list of guidelines at
            //   http://go.microsoft.com/fwlink/?LinkID=85237  
            // and also the guidance for operator== at
            //   http://go.microsoft.com/fwlink/?LinkId=85238
            //
            
            VisibleAttribute other = obj as VisibleAttribute;
            if (other == null) return false;
            return other._visible == this._visible;
        }

        // override object.GetHashCode
        public override int GetHashCode()
        {
            return _visible.GetHashCode();
        }

        public static readonly VisibleAttribute Yes = new VisibleAttribute(true);

        public static readonly VisibleAttribute No = new VisibleAttribute(false);

        public static readonly VisibleAttribute Default = Yes;
    }
}
